<!DOCTYPE HTML>
<html>
<head>
	<title>我的个人博客</title>
	<meta charset="utf8">
	<link rel="stylesheet" type="text/css" href="style.css">
	<link rel="icon" type="image/png" href="simbs.png">
</head>
<body>

<div class="top">
	<div class="header">
                <div class="logo">
                        <a href="index.php"><img src="logo.png"/></a>
                </div>
		<div id="container">
			<ul>
<?php
	//调用文件CatalogService.class.php
	require_once 'CatalogService.class.php';
	$catalogService = new CatalogService();
	echo $catalogService->navigation();
?>
			</ul>
		</div>
	</div>
	<div class="single">
<?php

	//调用pager.class.php.BlogService.class.php
	require_once 'BlogService.class.php';
	require_once 'pager.class.php';
	
	$pager = new pager();

	//设置页码
	if(!empty($_GET['pageNow'])){
		$pager->pageNow = $_GET['pageNow'];
	}else{
		$pager->pageNow = 1;
	}
	
	$pager->pageSize = 6;
	
	//创建blogService对象
	$blogService = new BlogService();
	//如果接受到$_GET['trashed']='1'以及$_GET['id'],则删掉那个id的文章
	 if(!empty($_GET['trashed'])){
		$id = $_GET['id'];
		$blogService->trashedBlog($id);	
	}

	$blogService->getPager($pager);
	for($i=0;$i<count($pager->res_array);$i++){
		$row = $pager->res_array[$i];
		$id = $row['id'];
		echo "<div id='title'><a href='blogPage.php?id=$id'><h2>{$row['title']}</h2></a></div>";
		echo "<div id='content'><a href='blogPage.php?id=$id'><p>{$row['content']}</p></a></div>";	
	}
	
	
	//显示分页下的导航栏
	echo $pager->navend;
?>
	</div>
	<div class="sidebar">
		<div class="loginSuccess">
			<?php
				session_start();
				if(!empty($_SESSION['name'])){
				echo "当前用户: ".$_SESSION['name']."<br />";
                                echo "<a href='blogList.php'>管理博文</a><br/>";
                                echo "<a href='blogAdd.php'>添加博文</a><br/>";
                                echo "<a href='configManage.php'>管理设置</a><br/>";
				echo "<a href='login.php'>重新登录</a>";
				} else{
				echo "<a href='login.php'>用户登录</a>";
				}
                ?>      

		</div>
                <div class="latest">最近更新
                <ul>
<?php
	//调用文件BlogService.php
	require_once 'BlogService.class.php';
	$blogService = new BlogService();
	echo $blogService->getLatestBlogTitle(10);
?>
                </ul>
        </div>
	</div>
	<div id="footer">
		<p>Copyright &#169;2012 Powered by <a href="http://code.google.com/p/simbs/">simbs</a> </p>
	</div>
</div>
</body>
</html>
